﻿Imports BE.BE
Imports BL.BL

Public Class frmGestionContrapartes
    Dim mlista As List(Of Contraparte_BE)

    Private Sub frmGestionContrapartes_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            'Helper_FL.setearPermisos(frmPrincipal.usr, Me)

            mlista = Contraparte_BL.listarContrapartes
        Catch ex As Exception
            MsgBox(ex)
        End Try
        
        Me.DataGridView1.DataSource = mlista

    End Sub


    Private Sub btnClienteNuevo_Click(sender As Object, e As EventArgs) Handles btnClienteNuevo.Click
        Dim mcontra As New Contraparte_BE

        mcontra.Apellido = Me.TextBox1.Text
        mcontra.Nombre = Me.txtNombre.Text
        mcontra.DNI = Me.TextBox4.Text
        mcontra.FechaNacimiento = Me.TextBox2.Text

        Dim mtel As New Telefono_BE

        mtel.Numero = Me.TextBox3.Text


        mcontra.Telefonos.Add(mtel)

        mtel = New Telefono_BE

        mtel.Numero = Me.TextBox5.Text


        mcontra.Telefonos.Add(mtel)

        Try
            Contraparte_BL.altaContraparte(mcontra)

            mlista = Contraparte_BL.listarContrapartes
        Catch ex As Exception
            MsgBox(ex)
        End Try
        

        Me.DataGridView1.DataSource = mlista

    End Sub
End Class